package com.cbs.java.component.network;

import okio.*;

import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;

/**
 * Created by broche on 11/3/15.
 */
public class DebugBufferedSink implements BufferedSink {
    private StringBuilder stringBuilder = new StringBuilder();

    @Override
    public Buffer buffer() {
        stringBuilder.append("[buffer()]");
        return null;
    }

    @Override
    public BufferedSink write(ByteString byteString) throws IOException {
        stringBuilder.append(byteString.utf8());
        return this;
    }

    @Override
    public BufferedSink write(byte[] bytes) throws IOException {
        stringBuilder.append("[write(byte[] bytes)]");
        return this;
    }

    @Override
    public BufferedSink write(byte[] bytes, int i, int i1) throws IOException {
        stringBuilder.append(new String(bytes, i, i1));
//        stringBuilder.append("[write(byte[] bytes, int i, int i1)]");
        return this;
    }

    @Override
    public long writeAll(Source source) throws IOException {
        stringBuilder.append("[writeAll(Source source)]");
        return 0;
    }

    @Override
    public BufferedSink write(Source source, long l) throws IOException {
        stringBuilder.append("[write(Source source, long l)]");
        return this;
    }

    @Override
    public BufferedSink writeUtf8(String s) throws IOException {
        stringBuilder.append("[writeUtf8(String s)]");
        return this;
    }

    @Override
    public BufferedSink writeUtf8(String s, int i, int i1) throws IOException {
        stringBuilder.append("[writeUtf8(String s, int i, int i1)]");
        return this;
    }

    @Override
    public BufferedSink writeUtf8CodePoint(int i) throws IOException {
        stringBuilder.append("[writeUtf8CodePoint(int i)]");
        return this;
    }

    @Override
    public BufferedSink writeString(String s, Charset charset) throws IOException {
        stringBuilder.append("[writeString(String s, Charset charset)]");
        return this;
    }

    @Override
    public BufferedSink writeString(String s, int i, int i1, Charset charset) throws IOException {
        stringBuilder.append("[writeString(String s, int i, int i1, Charset charset)]");
        return this;
    }

    @Override
    public BufferedSink writeByte(int i) throws IOException {
        stringBuilder.append("[writeByte(int i)]");
        return this;
    }

    @Override
    public BufferedSink writeShort(int i) throws IOException {
        stringBuilder.append("[writeShort(int i)]");
        return this;
    }

    @Override
    public BufferedSink writeShortLe(int i) throws IOException {
        stringBuilder.append("[writeShortLe(int i)]");
        return this;
    }

    @Override
    public BufferedSink writeInt(int i) throws IOException {
        stringBuilder.append("[writeInt(int i)]");
        return this;
    }

    @Override
    public BufferedSink writeIntLe(int i) throws IOException {
        stringBuilder.append("[writeIntLe(int i)]");
        return this;
    }

    @Override
    public BufferedSink writeLong(long l) throws IOException {
        stringBuilder.append("[writeLong(long l)]");
        return this;
    }

    @Override
    public BufferedSink writeLongLe(long l) throws IOException {
        stringBuilder.append("[writeLongLe(long l)]");
        return this;
    }

    @Override
    public BufferedSink writeDecimalLong(long l) throws IOException {
        stringBuilder.append("[writeDecimalLong(long l)]");
        return this;
    }

    @Override
    public BufferedSink writeHexadecimalUnsignedLong(long l) throws IOException {
        stringBuilder.append("[writeHexadecimalUnsignedLong(long l)]");
        return this;
    }

    @Override
    public BufferedSink emitCompleteSegments() throws IOException {
        stringBuilder.append("[emitCompleteSegments()]");
        return this;
    }

    @Override
    public BufferedSink emit() throws IOException {
        stringBuilder.append("[emit()]");
        return this;
    }

    @Override
    public OutputStream outputStream() {
        stringBuilder.append("[outputStream()]");
        return null;
    }

    @Override
    public void write(Buffer buffer, long l) throws IOException {
        stringBuilder.append("[write(Buffer buffer, long l)]");
    }

    @Override
    public void flush() throws IOException {
        stringBuilder.append("[flush()]");
    }

    @Override
    public Timeout timeout() {
        stringBuilder.append("[timeout()]");
        return null;
    }

    @Override
    public void close() throws IOException {
        stringBuilder.append("[close()]");
    }

    public String getContent() {
        return stringBuilder.toString();
    }
}
